/**
 * @date   2011-4-9
 * @author tianye
 */
package cn.edu.dlut.WingGame.Game;

import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import dalvik.system.VMRuntime;

public class WingActivity extends Activity {
	private final static float TARGET_HEAP_UTILIZATION = 0.75f;
	// 数据
	protected WingSceneContainer mContainer;
	// 绘图
	protected WingSurfaceView mWingView;
	protected WingRender mRender;
	// 循环更新
	protected WingLoop mLoop;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		VMRuntime.getRuntime()
				.setTargetHeapUtilization(TARGET_HEAP_UTILIZATION);
		// 游戏全屏幕
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		// 数据
		mContainer = new WingSceneContainer();
		// 设置绘图
		mWingView = new WingSurfaceView(this);
		mRender = new WingRender(this);
		mWingView.setRenderer(mRender);
		setContentView(mWingView);
		// 开始循环
		mLoop = new WingLoop();
		mLoop.setFPS(24);
		mLoop.startLoop();
	}

	@Override
	protected void onPause() {
		super.onPause();
		mWingView.onPause();
		mLoop.stopLoop();
	}

	@Override
	protected void onResume() {
		super.onResume();
		mWingView.onResume();
		mLoop.startLoop();
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		mLoop.stopLoop();
	}

}
